{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Visualizing Uniform Probability Distributions\n",
    "\n",
    "Do you remember from the lesson videos what the spinning bottle's probability distribution looked like?\n",
    "\n",
    "\n",
    "Because the probability of landing at any angle between 0 and 360 is equal, the spinning bottle has a continuous uniform probability distribution. This distribution looked like a rectangle.\n",
    "\n",
    "You could use a line chart to make this visualization. Here is an example of a continuous distribution where the minimum value was 100 and the maximum possible value 500.\n",
    "\n",
    "![continuous distribution](continuous_distribution_example.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Exercise\n",
    "\n",
    "In the cell below, write a function called uniform_distribution_height that outputs the height of a uniform continuous probability distribution.\n",
    "\n",
    "The function has two inputs:\n",
    "* x_minimum - contains the minimum value of the distribution\n",
    "* x_maximum - contains the maximum value of the distribution\n",
    "\n",
    "For example, the spinning bottle had x_minimum = 0 and x_maximum = 360. You can find the height knowing that the area of the rectangle forming the probability distribution is 1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "def uniform_distribution_height(x_minimum, x_maximum):\n",
    "    \n",
    "    # TODO: calculate the height of the uniform continuous\n",
    "    # probability distribution based on x_minimum and x_maximum.\n",
    "    \n",
    "    height = 1.0 / x_maximum - x_minimum\n",
    "    return height"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Visualizing the Results\n",
    "\n",
    "Run the code cell below to visualize the results based on the spinning bottle probability distribution."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "y = uniform_distribution_height(0, 360)\n",
    "\n",
    "plt.plot([0, 360], [y, y], color='blue')\n",
    "plt.plot([0, 0], [0, y], '--', color='blue', )\n",
    "plt.plot([360, 360], [0, y], '--', color='blue', )\n",
    "plt.ylim([0, y + y/2])\n",
    "\n",
    "plt.xlabel('Degrees')\n",
    "plt.ylabel('Probability Distribution')\n",
    "plt.title('Uniform Probability Distribution \\n for a Spinning Bottle')\n",
    "plt.xticks(range(0, 361, 30))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If your uniform_distribution_height() function is correct, the visualization should look like this:\n",
    "\n",
    "![continuous distribution](continuous_distribution.png)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
